package com.rd.student.jike.class1.sunhao.day0807;

import java.io.*;
import java.util.Arrays;

public class DaLetou {
    public static void main(String[] args) throws IOException {
        Writer writer = new FileWriter("Daletou.txt");
        String str = KiJiang();
        char[] chars = str.toCharArray();
        writer.write(chars);
        writer.close();
        Writer writer1 = new FileWriter("randomDLT.txt");
        for (int i = 0; i < 1000; i++) {
            String str1 = KiJiang();
            String str2 = str1 + "\n";
            char[] chars1 = str2.toCharArray();
            writer1.write(chars1);
        }
        writer1.close();
        Reader reader = new FileReader("randomDLT.txt");
        Reader reader1 = new FileReader("Daletou.txt");
        char[] chars1 = new char[24];
        char[] chars2 = new char[chars.length];
        reader1.read(chars2);
        int result=0;
        for (int i = 0; i < 1000; i++) {
            reader.read(chars1);
            String str1 = new String(chars1);
            String str2 = new String(chars2);
            str2 = str2 + "\n";
            if (str1.equals(str2)) {
                System.out.println("第" + i + "组号码中奖了" + Arrays.toString(chars1));
                result++;
            }
        }
        if (result==0){
            System.out.println("真可惜，没中奖!");
        }
    }

    public static int[] SuiJi(int sum) {
        int[] ints = new int[sum];
        e:
        for (int i = 0; i < sum; i++) {
            int j = (int) ((Math.random() * 35) + 1);
            for (int k = 0; k <= i; k++) {
                if (ints[k] == j) {
                    i--;
                    continue e;
                }
            }
            ints[i] = j;
        }
        return ints;
    }

    public static int[] SuiJi1(int sum) {
        int[] ints = new int[sum];
        e:
        for (int i = 0; i < sum; i++) {
            int j = (int) ((Math.random() * 12) + 1);
            for (int k = 0; k <= i; k++) {
                if (ints[k] == j) {
                    i--;
                    continue e;
                }
            }
            ints[i] = j;
        }
        return ints;
    }

    public static String KiJiang() {
        int[] ints = SuiJi(5);
        int[] ints1 = SuiJi1(2);
        String str = "";
        for (int i = 0; i < 8; i++) {
            if (i < 5) {
                if (ints[i] < 10) {
                    str = str + "0" + ints[i] + " ";
                } else
                    str = str + ints[i] + " ";
            }
            if (i == 5) {
                str = str + "| ";
            }
            if (i > 5) {
                if (ints1[i - 6] < 10) {
                    str = str + '0' + ints1[i - 6] + " ";
                } else
                    str = str + +ints1[i - 6] + " ";
            }
        }
        return str;
    }
}

